//
//  OrderHeader.m
//  HMMarket
//
//  Created by 孙鹏飞 on 2017/5/10.
//  Copyright © 2017年 homai. All rights reserved.
//

#import "OrderHeader.h"

@interface OrderHeader ()

@property (weak, nonatomic) IBOutlet UILabel *orderNum;

@property (weak, nonatomic) IBOutlet UILabel *orderTime;

@end

@implementation OrderHeader

+ (instancetype)orderHeader
{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
}

-(void)setModel:(OrderModel *)model
{
    _model = model;
    
    _orderNum.text = [NSString stringWithFormat:@"订单号：%@",model.oid];
    NSNumber * date = [NSNumber numberWithFloat:[_model.addtime floatValue]];
    _orderTime.text = [self dateStringWithNumber:date];
}

#pragma mark时间戳转成字符串
- (NSString *)dateStringWithNumber:(NSNumber *)dateNumber
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YYYY-MM-dd"];
    NSTimeInterval time = [dateNumber doubleValue];
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:time];
    NSString *str = [dateFormatter stringFromDate:date];
    return str;
}

@end
